home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-03-19 | 61.3 KB | 1,892 lines | [TEXT/MPS ] |
- #########################################################################
- #########################################################################
- ## Copyright © Apple Computer, Inc. 1993-1998
- ## All rights reserved
- #########################################################################
- #########################################################################
- #
- # Library: MemoryCP.lib
- #
- # Version: 2.1.5
- #
- # Description:
- # Sets any section of the Memory Control Panel to any possible value.
- #
- # This is a complex set of tasks, for several reasons:
- # a) Most of the items in the window are not VU visible and they have
- # to be read by direct screen access. This especially applies to
- # all the numbers. The VU visible items can not be selected by VU
- # because their locations are horizontally offset by -89 pixels.
- # THIS HAS BEEN FIXED IN VU 2.1!!!!!
- # b) The window size and contents change, depending on which features
- # are available on the target CPU. For example, some CPUs have a
- # 32-bit Addressing section, others do not. The sections below
- # a "variable" section move up or down to make room.
- # c) Setting some sections affects the possible settings of others.
- # The sections must be set in a particular order to take this
- # into account. Some examples:
- # 32-Bit Addressing affects the maximum VM amount.
- # RAM Disk affects the minimum VM and maximum Disk Cache amounts.
- # Use Defaults affects all other sections.
- # d) The caller may want to set every section, only one section,
- # or a subset of all sections, and should not have to wait or
- # supply "empty" values for the other sections.
- # e) Some requests can only be fulfilled on a "close enough" basis.
- # If the caller asks for a RAM Disk amount of 1024K, there may be
- # enough RAM, but the actual settings possible by using the slider
- # may be 1120K on the low side and 1440K on the high side. In such
- # cases close enough is considered good enough. However, the caller
- # must be the final arbiter of this. For comparison, the actual
- # settings of each section are returned with the desired settings
- # but no error is generated.
- # f) After all this, the architecture must support the addition of
- # new sections not currently implemented. For example, the PowerPC
- # Memory Control Panel contains a Memory Manager section not found
- # on any previous CPU. Adding this was relatively easy since
- # the architecture already supported movable sections.
- #
- # The main task calculates the locations of all sections, and stores
- # these values. Each section has its own task which uses the stored
- # locations to figure out where to look and where to click. The main
- # task calls each one in turn, then collects and returns the results.
- #
- #
- # Contains:
- # memoryCP_getWindowItems()
- # memoryCP_setDiskCache()
- # memoryCP_setModMemMgr()
- # clickVMOnButton()
- # memoryCP_setVM()
- # memoryCP_set32Bit()
- # memoryCP_setRAMDisk()
- # memoryCP_setUseDefaults()
- #
- # History:
- # Date: By: Changes:
- # 01/12/93 SBR Created
- # 05/29/93 SBR Added Heap Style section for PowerPC, see
- # memoryCP_setModMemMgr().
- # 06/15/93 SBR Added v_level to reporting, set debugging reporting
- # to v_level + 1.
- # 07/20/93 SBR Removed Heap Style section. Its User Interface status
- # is uncertain.
- # 09/01/93 SBR Moved debugging "if" to after the return values are
- # defined.
- # 09/07/93 SBR Added section for PowerPC, see memoryCP_setModMemMgr().
- # 11/27/93 SBR Cleaned up comments and formatting, small bug fixes.
- # 03/10/95 SBR Modified for exclusive use with VU 2.1 (VU is at
- # 2.1a3e12 now).
- # Changed task from memoryCP_setNewMemMgr() to
- # memoryCP_setModMemMgr().
- # 09/27/96 BRL/MSO Updated copyright header
- # Use SPEC exception handling method (ExceptionHandling.lib)
- # 01/21/97 SBR Deleted older exception code and comments.
- # 03/20/97 SBR Updated for Mac OS 8.0.
- # 02/19/98 SBR Updated for Mac OS 8.1, removed code for non-GM 8.0.
- # 03/10/98 CTE Removed remainder of code for non-GM 8.0.
- #
- #########################################################################
- #########################################################################
- Libraries
- "Additions.lib",
- "Clouseau.lib",
- "ReadGeneva9Numbers.lib",
- "Report.lib",
- "TargetControl.lib",
- "VUAid.lib",
- "ExceptionHandling.lib";
-
- #########################################################################
- # task MemoryCP()
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: The user-callable task, divides up the work among all the internal tasks.
- # Parameters:
- # myMems:
- # There are 3 basic ways to use this parameter:
- # (1) Set the entire Memory CP by putting an assoc() list into myMems:
- # myMems := { {diskCacheList},
- # {modMemMgrList},
- # {vmList},
- # {addr32BitList},
- # {ramDiskList},
- # {miscList}
- # };
- # All items in myMems are optional. If an item is not in the list it is
- # ignored. The items contain IDs so they can be in any order.
- #
- # WARNING: Clicking 'Use Default' may change values you want to ignore. For
- # example, it changes the disk cache size, turns off 32-Bit and RAM Disk,
- # and sets the VM Backing Store volume to the startup volume. This task
- # currently does not restore any values after clicking 'Use Default'.
- #
- # WARNING: If the RAM Disk holds any items you can not change its settings.
- # This task logs an error message if you attempt any action with the RAM
- # Disk when the Memory CP has disabled its controls.
- #
- # diskCacheList:
- # { 'dc',
- # the second item is one of the following:
- # 'xK': (x > 0) the value in KB
- # 'random': choose from the list of 23 values
- # (see dcValues in memoryCP_setDiskCache)
- # 'read': return the value present before changes
- # 'no change': recover from Use Defaults (not implemented)
- # '': ignore this section
- # }
- #
- # modMemMgrList:
- # { 'mm',
- # the second item is one of the following:
- # 'On': click On if not already selected
- # 'Off': click Off if not already selected
- # 'random': click On or Off randomly
- # 'read': return the value present before changes
- # 'no change': recover from Use Defaults (not implemented)
- # '': ignore this section
- # }
- #
- # vmList:
- # { 'vm',
- # the second item in vmList is itself a list
- # {
- # the first item is one of the following:
- # 'On': click On if not already selected
- # 'xM': (x > 0) click On, set the value to xM
- # 'x%': (0 <= x <= 100) click On, use up x % of available
- # 'Off': click Off if not already selected
- # 'Min': set VM to minimum
- # 'Max': set VM to maximum (available on disk - 1M)
- # 'auto': let Memory CP automatically choose value by
- # turning VM Off then On after setting all others
- # 'random': choose from minimum to maximum
- # 'read': return the value present before changes
- # 'no change': recover from Use Defaults (not implemented)
- # '': ignore this section
- #
- # ,
- #
- # the second item is one of the following:
- # '': ignore bs volume setting (currently the only choice)
- # bs: the string name of the backing store volume (not yet)
- # }
- # }
- #
- # addr32BitList:
- # { '32',
- # the second item is one of the following:
- # 'On': click On if not already selected
- # 'Off': click Off if not already selected
- # 'random': click On or Off randomly
- # 'read': return the value present before changes
- # 'no change': recover from Use Defaults (not implemented)
- # '': ignore this section
- # }
- #
- # ramDiskList:
- # { 'rd',
- # the second item is one of the following:
- # 'xK': (0 <= x <= 32767) size in KB (click On or Off as needed)
- # 'x%': (0 <= x <= 100) set to % of 125 pixel positions (fast)
- # 'x%!': (0 <= x <= 100) set to % of max - min (slow, accurate)
- # 'Off': click Off
- # 'Min': set to minimum size
- # 'Max': set to maximum size
- # 'random': drags slider from min to to random(0,125) with 0 = Off
- # 'read': return the value present before changes
- # 'VMOn': set size just high enough to allow use of VM (not yet)
- # 'no change': recover from Use Defaults (not implemented)
- # '': ignore this section
- # }
- #
- # useDefaultsList:
- # { 'ud',
- # 'click' : click Use Defaults before setting other sections
- # '': ignore this section
- # }
- #
- # (2) Attempt to default to standard system 7.0-7.1 settings, equivalent to
- # SetMemoryCP({ { 'vm',{ 'Off','' } },{ 'ud', 'click' } }). Usually this results
- # in Disk Cache at default, VM Off, 24-bit, RAM Disk Off. However, in some
- # systems 32-Bit is always On, and the warnings above always apply.
- # (3) Return the current settings by putting the string 'readOnly' in myMems.
- # verbosity_level: verbosity level to push during this script
- # reset_target: calls reset() at the beginning
- # Returns: { error, previousSettings, askedSettings, currentSettings}
- # error: 0 for no error, non-zero for error
- # previousSettings: the settings before making any changes
- # askedSettings: myMems
- # currentSettings: may not be the same as asked Settings
- # Examples:
- # (1) saveMemory := MemoryCP({{ 'dc','256K' },{ 'vm',{ '27M','' } },{ '32','On' },
- # { 'rd','1024K'} }, 3);
- # ...
- # MemoryCP(saveMemory[2]);
- # (2) MemoryCP({});
- # (3) theMemory := MemoryCP('readOnly');
- # Assumptions: Uses VU 2.1 and VUAid 2.1. Bit depth is 1,2,4,8,16, or 32.
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 01/12/93 SBR Created
- # 04/09/95 SBR Closes the control panel when finished.
- # 09/27/96 BRL/MSO Added SPEC exception handling
- #########################################################################
- task MemoryCP ( myMems := {
- #mydc :=
- {'dc','96K'},
- #mymm :=
- {'mm','On'},
- #myvm :=
- {'vm',{'Off',''}},
- #my32 :=
- {'32','On'},
- #myrd :=
- {'rd','Off'},
- #myud :=
- {'ud','click'},
- #myq :=
- 'quick'
- }
-
- #THE LINES BELOW ARE FOR DEVELOPMENT AND ARE NORMALLY COMMENTED OUT >>>>
- # ,
- # repeat_for := 1, #SBR dev code
- # make_alias := false,
- # reset_target := false,
- # tracer := false
- # THE LINES ABOVE ARE FOR DEVELOPMENT AND ARE NORMALLY COMMENTED OUT <<<<
-
- ,v_level := 4
- )
- begin
- global gmcp; # Global Memory Control Panel (gmcp) is an assoc list of visible sections
-
- VUAidReturnLongIntegers();
-
- #THE LINES BELOW ARE FOR DEVELOPMENT AND ARE NORMALLY COMMENTED OUT >>>>
- # RPushVerbosity(2);
- #
- # if typeOf(v_level) = 'string'
- # begin
- # v_level := strToNum(v_level);
- # rPushVerbosity(v_level);
- # v_level := 4;
- # end;
- # RStatus('memoryCP script',v_level);
- # if reset_target
- # key_eq('w'); #SBR dev stuff
- # if isUndefined(myMems)
- # myMems := { mydc, mymm, myvm, my32, myrd, myud, myq };
- # if make_alias
- # alias_control_panel('Memory');
- #THE LINES ABOVE ARE FOR DEVELOPMENT AND ARE NORMALLY COMMENTED OUT <<<<
-
- saveSpeed := MouseSpeed(0);
-
- ## OPEN MEMORY CP
- if not memoryCP_getWindowItems()
- return { -1, {}, {}, {}};
-
- #THE LINES BELOW ARE FOR DEVELOPMENT AND ARE NORMALLY COMMENTED OUT >>>>
- # if card myrd = 3
- # begin
- # specialRAMDisk := true;
- # theRDValue := myrd[1];
- # theRDInterval := myrd[2];
- # theRDMax := myrd[3];
- # end;
- # for iterations := 1 to repeat_for
- # begin
- # isVUAidInstalled();
- # if specialRAMDisk
- # begin
- # theRDValue := theRDValue + theRDInterval;
- # if theRDValue > theRDMax
- # repeat_for := 1;
- # myMems[5] := { 'rd',"{numToStr(theRDValue)}K" };
- # #println "Begin setting the Memory Control Panel with {myMems[5]}";
- # end;
- # else
- # begin
- # println "Begin setting the Memory Control Panel";
- # end;
- # startTime := _Match([time]);
- # #println "iteration {iterations}";
- #THE LINES ABOVE ARE FOR DEVELOPMENT AND ARE NORMALLY COMMENTED OUT <<<<
-
- quickSet := false;
- if myMems = 'readOnly'
- begin
- newDCValue := 'read';
- newMMValue := 'read';
- newVMValue := 'read';
- new32Value := 'read';
- newRDValue := 'read';
- newUDValue := '';
- end;
- else begin
- if not myMems #default settings for sys 7.0-7.1-7.5 (they may differ)
- myMems := { { 'vm', { 'Off', '' } }, {'ud', 'click'} };
- newDCValue := assoc('dc', myMems);
- newVMValue := assoc('vm', myMems); # get the setting request for each section
- newMMValue := assoc('mm', myMems);
- new32Value := assoc('32', myMems);
- newRDValue := assoc('rd', myMems);
- newUDValue := assoc('ud', myMems);
- if isMember('quick',myMems)
- quickSet := true;
- end;
-
- if not quickSet # quickSet false: read pertinent values before setting
- begin
- if newVMValue
- begin
- if typeOf( newVMValue ) = 'list'
- previousVM := 'readMe';
- if typeOf( newVMValue ) = 'string'
- if newVMValue <> 'read'
- previousVM := 'readMe';
- if previousVM = 'readMe'
- previousVM := memoryCP_setVM('read')[3]; #read VM before setting 32-Bit
- end;
- if newDCValue and newDCValue <> 'read'
- previousDC := memoryCP_setDiskCache('read')[3]; #read DC before setting RAM Disk
-
- if newUDValue
- begin
- if newRDValue and newRDValue <> 'read'
- previousRD := memoryCP_setRAMDisk('read')[3]; #read RD, 32, and MM
- if new32Value and new32Value <> 'read'
- previous32 := memoryCP_set32Bit('read')[3]; #before clicking Use Defaults
- if newMMValue and newMMValue <> 'read'
- previousMM := memoryCP_setModMemMgr('read')[3];
- end;
- end;
-
- # CAUTION: The modules must execute in this order because of dependencies between sections
-
- temp1 := memoryCP_setUseDefaults(newUDValue);
- if temp1[4]
- RStatus(temp1[4],v_level);
-
- temp2 := memoryCP_set32Bit(new32Value);
- if temp2[2] and previous32
- temp2[2] := previous32;
- if temp2[4]
- RStatus(temp2[4],v_level);
-
- temp3 := memoryCP_setRAMDisk(newRDValue);
- if temp3[2] and previousRD
- temp3[2] := previousRD;
- if temp3[4]
- RStatus(temp3[4],v_level);
-
- temp4 := memoryCP_setDiskCache(newDCValue);
- if temp4[2]
- temp4[2] := previousDC;
- if temp4[4]
- RStatus(temp4[4],v_level);
-
- temp5 := memoryCP_setVM(newVMValue);
- if temp5[2]
- temp5[2] := previousVM;
- if temp5[4]
- RStatus(temp5[4],v_level);
-
- temp6 := memoryCP_setModMemMgr(newMMValue);
- if temp6[2]
- temp6[2] := previousMM;
- if temp6[4]
- RStatus(temp6[4],v_level);
-
- previousSettings :=
- {
- { 'dc', temp4[2] },
- { 'mm', temp6[2] },
- { 'vm', temp5[2] },
- { '32', temp2[2] },
- { 'rd', temp3[2] },
- { 'ud', temp1[2] }
- };
- askedSettings :=
- {
- { 'dc', newDCValue },
- { 'mm', newMMValue },
- { 'vm', newVMValue },
- { '32', new32Value },
- { 'rd', newRDValue },
- { 'ud', newUDValue }
- };
- currentSettings :=
- {
- { 'dc', temp4[3] },
- { 'mm', temp6[3] },
- { 'vm', temp5[3] },
- { '32', temp2[3] },
- { 'rd', temp3[3] },
- { 'ud', temp1[3] }
- };
-
- error := temp1[1] or temp2[1] or temp3[1] or temp4[1] or temp5[1];
- VUAid('quit');
-
- #THE LINES BELOW ARE FOR DEVELOPMENT AND ARE NORMALLY COMMENTED OUT >>>>
- # #if R_BeVerbose(v_level) #for diagnostics
- # begin
- # println "previous MemoryCP:";
- # println '{';
- # for i := 1 to (card previousSettings) - 1
- # println previousSettings[i], ',';
- # println previousSettings[card previousSettings];
- # println '{';
- #
- # println "asked MemoryCP:";
- # println '{';
- # for i := 1 to (card askedSettings) - 1
- # println askedSettings[i], ',';
- # println askedSettings[card askedSettings];
- # println '{';
- #
- # println "current MemoryCP:";
- # println '{';
- # for i := 1 to (card currentSettings) - 1
- # println currentSettings[i], ',';
- # println currentSettings[card currentSettings];
- # println '{';
- # end;
- #
- # print 'End setting the Memory Control Panel ';
- # println time_str(time_sub(_Match([time]), startTime));
- # println { error, previousSettings, askedSettings, currentSettings} ;
- # end;
- #THE LINES ABOVE ARE FOR DEVELOPMENT AND ARE NORMALLY COMMENTED OUT <<<<
-
- key_eq('w');
- MouseSpeed(saveSpeed);
- return { error, previousSettings, askedSettings, currentSettings};
- end; # MemoryCP
-
- #########################################################################
- # Task memoryCP_getWindowItems( v_level )
- # Description: Collects data used in the Memory CP. These include the window
- # relative locations of the sections and the corrected coordinates
- # of the visible controls. Here are all possible sections as of
- # 08/25/94. In practice gmcp is smaller, because no Macintosh has
- # both Modern Memory Manager and 32-Bit Addressing sections.
- # global gmcp :=
- # {
- # { 'win',{ windowRect } },
- # { 'dc',{ dcLeftTop } },
- # { 'mm',{ mmLeftTop,[mmOff],[mmOn] } },
- # { 'vm',{ vmLeftTop,[vmOff],[vmOn] } },
- # { '32',{ 32LeftTop,[32Off],[32On] } },
- # { 'rd',{ rdLeftTop,[rdSlider],[rdOff],[rdOn] } },
- # { 'ud',{ udLeftTop,[ud] } } }
- # };
- # Parameters: v_level
- # Returns: successful: true
- # unsuccessful: false
- # History:
- # 01/23/93 SBR Created
- # 05/29/93 SBR Added New Heap section for PowerPC
- # 07/20/93 SBR Removed Heap Style section. Its User Interface status is uncertain.
- # 09/07/93 SBR Added Memory Manager section for PowerPC.
- # 04/06/94 GKratzer Changed verbosity level for open_control_panel call to 4.
- # 09/27/96 BRL/MSO Added SPEC exception handling
- # 03/20/97 SBR Changed v_level to 4.
- # Pre-calculate left-top values for sections.
- # Special-case item locations for 8.0.
- # Fixed Radar 1272363.
- # 02/23/98 SBR Changed version match from /v7.≈/ to /v[0-9].≈/ .
- # Added case 48 for Mac OS 8.1 item list.
- #########################################################################
- Task memoryCP_getWindowItems( v_level := 4 )
- begin
- global gmcp;
-
- if not isUndefined(gmcp) # skip to save time if it looks like the same window
- if _MatchBoolean( [window t:'Memory' o:1 b:assoc('win',gmcp)[1]], true)
- return true;
-
- RStatus('Opening the Memory control panel.',v_level);
-
- if not (_MatchBoolean([window t:'Memory' o:1]) AND _MatchBoolean([application t:'Finder']))
- open_control_panel('Memory',,4);
-
-
- # Drag Memory CP to the main screen only if a portion is hidden (Radar 1272363).
- # Use the window rectangle (r:) trait for this comparison
- try
- match [window t:'Memory' o:1 r:?windowRect];
- catch theError
- ExceptionDispatcher(theError,,{"match 1 in memoryCP_getWindowItems", {v_level}});
-
- screenRect := _Match([screen m:true], true).r;
- if ((windowRect[1] < screenRect[1]) or
- (windowRect[2] < screenRect[2]) or
- (windowRect[3] > screenRect[3]) or
- (windowRect[4] > screenRect[4]))
- begin
- _Drag([window t:'Memory' o:1], 'a', {5,20});
- end;
-
-
- # Use the window bounds (b:) trait to work inside the window.
- try
- match [window t:'Memory' o:1 b:?windowRect];
- catch theError
- ExceptionDispatcher(theError,,{"match 2 in memoryCP_getWindowItems", {v_level}});
-
- try
- match [control t:$cN o:$cO s:$cS e:$cE r:$cR w:1];
- catch theError
- ExceptionDispatcher(theError,,{"memoryCP_getWindowItems 2", {v_level}});
-
- udOrdinal := cO[isMember('Use Defaults',cN)]; # which ordinality is Use Defaults?
- RStatus("Use Defaults is ordinality {udOrdinal}.",v_level);
- RStatus("MemCP version {_Match([staticText t:/v[0-9].≈/])} .",v_level);
- switch udOrdinal
- begin
- case 48: # System 8.1
- begin
- # assign empty descriptors for controls until real one is found
- mItems := {
- [], # o:(0) Modern Memory Manager 'Off' not in this version
- [], # o:(0) Modern Memory Manager 'On' not in this version
- [], # o:43 RAM Disk 'RAM Disk Slider' (boring...)
- [], # o:45 RAM Disk 'Off'
- [], # o:46 RAM Disk 'On'
- [], # o:48 'Use Defaults'
- [], # o:(0) 32-Bit 'Off' not in this version
- [], # o:(0) 32-Bit 'On' not in this version
- [], # o:53 VM 'Off'
- [], # o:54 VM 'On'
- [] # o:52 VM 'Select Hard Disk:'
- };
-
- #Ordinality within the MemCP window of all items in mItems, by index
- mItemsOrdinals := { 0, 0, 43, 45, 46, 48, 0, 0, 53, 54, 52 };
-
- end;
- case 49: # System 8.0
- begin
- # assign empty descriptors for controls until real one is found
- mItems := {
- [], # o:(0) Modern Memory Manager 'Off' not in this version
- [], # o:(0) Modern Memory Manager 'On' not in this version
- [], # o:44 RAM Disk 'RAM Disk Slider' (boring...)
- [], # o:46 RAM Disk 'Off'
- [], # o:47 RAM Disk 'On'
- [], # o:49 'Use Defaults'
- [], # o:(0) 32-Bit 'Off' not in this version
- [], # o:(0) 32-Bit 'On' not in this version
- [], # o:54 VM 'Off'
- [], # o:55 VM 'On'
- [] # o:53 VM 'Select Hard Disk:'
- };
-
- #Ordinality within the MemCP window of all items in mItems, by index
- mItemsOrdinals := { 0, 0, 44, 46, 47, 49, 0, 0, 54, 55, 53 };
-
- end;
- case 56: # System 7.6
- begin
- # assign empty descriptors for controls until real one is found
- mItems := {
- [], # o:(0) Modern Memory Manager 'Off' not in this version
- [], # o:(0) Modern Memory Manager 'On' not in this version
- [], # o:52 RAM Disk 'Slide Me Baby!'
- [], # o:54 RAM Disk 'Off'
- [], # o:55 RAM Disk 'On'
- [], # o:56 'Use Defaults'
- [], # o:(0) 32-Bit 'Off' not in this version
- [], # o:(0) 32-Bit 'On' not in this version
- [], # o:59 VM 'Off'
- [] # o:60 VM 'On'
- };
-
- #Ordinality within the MemCP window of all items in mItems, by index
- mItemsOrdinals := { 0, 0, 52, 54, 55, 56, 0, 0, 59, 60 };
-
- end;
- case 54: # System 7.1.2, 7.5, etc.
- begin
- # assign empty descriptors for controls until real one is found
- mItems := {
- [], # o:49 Modern Memory Manager 'Off'
- [], # o:50 Modern Memory Manager 'On'
- [], # o:51 RAM Disk 'Slide Me Baby!'
- [], # o:52 RAM Disk 'Off'
- [], # o:53 RAM Disk 'On'
- [], # o:54 'Use Defaults'
- [], # o:55 32-Bit 'Off'
- [], # o:56 32-Bit 'On'
- [], # o:57 VM 'Off'
- [] # o:58 VM 'On'
- };
-
- #Ordinality within the MemCP window of all items in mItems, by index
- mItemsOrdinals := { 49, 50, 51, 52, 53, 54, 55, 56, 57, 58 };
-
- end;
- case 45: # System 7.0.1, 7.1, 7.1.1
- begin
- # assign empty descriptors for controls until real one is found
- mItems := {
- [], # o:(0) Modern Memory Manager 'Off' not in this version
- [], # o:(0) Modern Memory Manager 'On' not in this version
- [], # o:42 RAM Disk 'Slide Me Baby!'
- [], # o:43 RAM Disk 'Off'
- [], # o:44 RAM Disk 'On'
- [], # o:45 'Use Defaults'
- [], # o:46 32-Bit 'Off'
- [], # o:47 32-Bit 'On'
- [], # o:48 VM 'Off'
- [] # o:49 VM 'On'
- };
-
- #Ordinality within the MemCP window of all items in mItems, by index
- mItemsOrdinals := { 0, 0, 42, 43, 44, 45, 46, 47, 48, 49 };
-
- end;
- default:
- begin
- RError("Can not identify this Memory CP version:",1);
- RError("MemCP version {_Match([staticText t:/v7.≈/])} .",1);
- RError("Use Defaults is ordinality {udOrdinal}, not 45, 54, 56, or 58.",1);
- RError("System {_Match([system])}",1);
- RError("Please be sure you are using Virtual User 2.1.4a1e4 or later.",1);
- return false;
- end;
- end;
-
- #Index (not ordinality) of all possible items in mItems
- mmOff := 1; mmOn := 2;
- rdSlider := 3; rdOff := 4; rdOn := 5;
- useDef := 6;
- b32Off := 7; b32On := 8;
- vmOff := 9; vmOn := 10; vmVolume := 11;
-
- mItemsCount := card mItems;
- for i := 1 to mItemsCount # fill each item which has a visible control
- begin
- j := isMember(mItemsOrdinals[i], cO);
- if j
- begin
- # 09/18/94 SBR: Removed for VU 2.1, it can retrieve them correctly
- # tempR := offset_list(cR[j],{-89, 0}); # remove Control Panel window horizontal offset
- mItems[i] := [control t:cN[j] o:cO[j] s:cS[j] e:cE[j] r:cR[j]];
- end;
- end;
-
- #save VU memory space by clearing large lists
- cN := undefined; cO := undefined; cS := undefined; cE := undefined; cR := undefined;
-
- dcHeight := 54; # pixel height of Memory CP sections
- mmHeight := 64;
- vmHeight := 95;
- b32Height := 64;
- rdHeight := 85;
-
- dcLeftTop := {windowRect[1],windowRect[2]}; #disk cache is always there
- gmcp :=
- {
- { 'win',{ windowRect } },
- { 'dc',{ dcLeftTop } }
- };
- gmcpNextIndex := 3; # VU 2.1 appends if assigning to an index of (card theList) + 1
-
- if mItems[mmOn]
- begin
- mmLeftTop := offset_list(dcLeftTop, {0,dcHeight});
- gmcp[gmcpNextIndex] := { 'mm',{ mmLeftTop,mItems[mmOff],mItems[mmOn] } } ;
- gmcpNextIndex := gmcpNextIndex + 1;
- end;
- else begin
- mmLeftTop := dcLeftTop;
- mmHeight := dcHeight;
- end;
-
- if mItems[vmOn]
- begin
- vmLeftTop := offset_list(mmLeftTop, {0,mmHeight});
- gmcp[gmcpNextIndex] := { 'vm',{ vmLeftTop,mItems[vmOff],mItems[vmOn] } };
- gmcpNextIndex := gmcpNextIndex + 1;
- end;
- else begin
- vmLeftTop := mmLeftTop;
- vmHeight := mmHeight;
- end;
-
- if mItems[b32On]
- begin
- b32LeftTop := offset_list(vmLeftTop, {0,vmHeight});
- gmcp[gmcpNextIndex] := { '32',{ b32LeftTop,mItems[b32Off],mItems[b32On] } };
- gmcpNextIndex := gmcpNextIndex + 1;
- end;
- else begin
- b32LeftTop := vmLeftTop;
- b32Height := vmHeight;
- end;
-
- if mItems[rdOn]
- begin
- rdLeftTop := offset_list(b32LeftTop, {0,b32Height});
- gmcp[gmcpNextIndex] := { 'rd',{ rdLeftTop,mItems[rdSlider],mItems[rdOff],mItems[rdOn] } };
- gmcpNextIndex := gmcpNextIndex + 1;
- end;
- else begin
- rdLeftTop := b32LeftTop;
- rdHeight := b32Height;
- end;
-
- udLeftTop := offset_list(rdLeftTop, {0,rdHeight});
- gmcp[gmcpNextIndex] := { 'ud',{ udLeftTop,mItems[useDef] } };
-
- RStatus( "memoryCP_getWindowItems gmcp = {gmcp}", v_level);
- return true;
- end;
-
-
- #########################################################################
- # Task memoryCP_setDiskCache( newDC , v_level )
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Sets the Disk Cache section of the Memory CP.
- # Parameters: newDC: see MemoryCP()
- # v_level: verbosity level
- # Returns: newDC contains a false value: { 0,'','','' }
- # no section of this type: false
- # read: { 0,"{current}K","{current}K",string }
- # set: { 0,"{previous}K","{new}K",string }
- # bad command: { -1,"{current}K","{current}K",string }
- # Examples: @@();
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 01/23/93 SBR Created
- # 09/27/96 BRL/MSO Added SPEC exception handling
- # 03/20/97 SBR Changed v_level to 4.
- # Use previously calculated left-top value.
- # Special-case size location for 8.0.
- #########################################################################
- Task memoryCP_setDiskCache( newDC := 'read', v_level := 4 )
- begin
- global gmcp;
- symbolicValue := '';
-
- if not newDC
- return {0,'','',''};
- RStatus("memoryCP_setDiskCache with newDC = {newDC}",v_level);
-
- memoryCP_getWindowItems();
- dcList := assoc('dc', gmcp);
-
- dcLT := dcList[1]; # Left Top of Disk Cache section in global coordinates
- move_mouse({'absolute',dcLT}); # Indicate current section to human
-
- dcValues := { 32,64,96,128, 192,256, 384,512, 768,1024,1536,2048,2560,3072,3584,
- 4096,4608,5120,5632,6144,6656,7168,7680 };
- numVals := card dcValues;
-
- tSys := _Match([system]).v;
- if (tSys ~= /7≈/)
- begin
- # 7.x has the "old correct" dcSizeOffset.
- dcSizeOffset := { 283,17 };
- end;
- else
- begin
- # 8.0 has the "new correct" dcSizeOffset.
- dcSizeOffset := { 284,17 };
- end;
-
- # dcIconLT := offset_list( dcLT, { 15,10 } ); # section icon Left Top (do not delete this line)
- dcUp := offset_list( dcLT, { 335,17 } ); # up arrow
- dcDown := offset_list( dcLT, { 335,27 } ); # down arrow
- dcSizeLT := offset_list( dcLT, dcSizeOffset ); # cache size 1st char Left Top
-
- oldDC := readGeneva9Number(dcSizeLT);
- oldDCRtnVal := "{oldDC}K";
-
- if newDC = 'read'
- return {0, oldDCRtnVal, oldDCRtnVal, "Current Disk Cache size is {oldDCRtnVal}"};
- else if newDC = 'random'
- begin
- symbolicValue := " ({newDC})";
- newDC := dcValues[random(1,card dcValues)]; #need better algorithm
- end;
- else begin
- lastChar := card newDC;
- theNum := '';
- for i := 1 to lastChar - 1
- theNum := theNum + newDC[i];
- theNum := strToNum(theNum);
- if newDC[lastChar] = 'K' and theNum > 0
- newDC := theNum;
- else begin
- return {-1, oldDCRtnVal, oldDCRtnVal,
- "memoryCP_setDiskCache: bad command: '{newDC}'."};
- end;
- end;
-
- originalNewDC := newDC;
- newSizeIndex := isMember(newDC, dcValues); # get index for new size
- if not newSizeIndex #condition desired size to the next lower size in the list
- begin
- hopeDCSize := newDC;
- if hopeDCSize < dcValues[1]
- newDC := dcValues[1];
- else if hopeDCSize > dcValues[numVals]
- newDC := dcValues[numVals];
- else begin
- i := 1;
- done := false;
- while not done
- begin
- if newDC < dcValues[i]
- begin
- done := true;
- newDC := dcValues[i - 1];
- end;
- else i := i + 1;
- end;
- end;
- newSizeIndex := isMember(newDC, dcValues); # redo with conditioned value
- end;
- oldSizeIndex := isMember(oldDC, dcValues); # get index for old size
- numClicks := newSizeIndex - oldSizeIndex;
- if numClicks < 0
- begin
- _Move('a', dcDown);
- numClicks := 0 - numClicks;
- end;
- else
- _Move('a', dcUp);
-
- for i := 1 to (numClicks / 10) #click slow so target won't lose events
- begin
- for j := 1 to 10
- _Click();
- wait(1);
- numClicks := numClicks - 10;
- end;
- for j := 1 to numClicks
- _Click();
-
- realDCSize := readGeneva9Number(dcSizeLT);
- returnMsg := "Set Disk Cache size to {realDCSize}K";
-
- if originalNewDC <> newDC
- returnMsg := returnMsg + " instead of {originalNewDC}K";
- return {0, oldDCRtnVal, "{realDCSize}K", "{returnMsg}{symbolicValue}."};
- end;
-
-
- #########################################################################
- # Task memoryCP_setModMemMgr( newMM , v_level )
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Sets the Modern Memory Manager section of the Memory CP.
- # Parameters: newMM: see MemoryCP()
- # v_level: verbosity level
- # Returns: newMM contains a false value: { 0,'','','' }
- # bad command, command failed, or no section of this type:
- # { -1,"{currentOffOn}","{currentOffOn}",string }
- # read: { 0,"{currentOffOn}","{currentOffOn}",string }
- # set: { 0,"{previousOffOn}","{newOffOn}",string }
- # Examples: @@();
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 09/08/93 SBR Created for PowerPC as memoryCP_setNewMemMgr
- # 03/10/95 SBR changed from memoryCP_setNewMemMgr to memoryCP_setModMemMgr
- # 09/27/96 BRL/MSO Added SPEC exception handling
- # 03/20/97 SBR Changed v_level to 4.
- # Use previously calculated left-top value.
- # Don't use VUAid to read the system heap type.
- #########################################################################
- Task memoryCP_setModMemMgr( newMM := 'read', v_level := 4 )
- begin
- global gmcp;
- symbolicValue := '';
-
- if not newMM
- return {0,'','',''};
- RStatus("memoryCP_setModMemMgr with newMM = {newMM}",v_level);
-
- memoryCP_getWindowItems();
- mmList := assoc('mm', gmcp);
-
- if mmList[3] # check Modern Memory Manager On button
- begin
- mmLT := mmList[1]; # Left Top of MMM section in global coordinates
- move_mouse({'absolute',mmLT}); # Indicate current section to human
-
- oldMM := _Match(mmList[3]).s[1];
- end;
- else
- begin # no Modern Memory Manager section visible
- # # Examine the system heap.
- # # Commented out because we don't want to read from low memory.
- # heapType := VUAid('GetMemory', {'byte', VUAid('GetMemory', {'long', 678}) + 30});
- # # println "HeapType: {heapType}";
- # oldMM := isMember( heapType,{ 3,7 } ); # heapTypes with Modern Memory Manager On
-
- # If System 7.6 or 8.0, and PowerPC, assume MM is on, otherwise assume off.
- oldMM := false;
- tSys := _Match([system]).v;
-
- if (tSys ~= /7.6≈/) or (tSys ~= /8≈/)
- begin
- if target_processor()[1] ~= /PPC≈/
- oldMM := true;
- else
- oldMM := false;
- end;
- end;
-
- if oldMM
- oldMMRtnVal := "On";
- else
- oldMMRtnVal := "Off";
-
- if newMM = 'read'
- return {0, oldMMRtnVal, oldMMRtnVal, "Current Modern Memory Manager setting is {oldMMRtnVal}"};
- else if newMM = 'random'
- begin
- symbolicValue := " ({newMM})";
- newMM := { 'Off','On' }[random(1,2)];
- end;
-
- if newMM <> oldMMRtnVal
- begin
- if newMM = 'On'
- clickRect := mmList[3].r;
- else if newMM = 'Off'
- clickRect := mmList[2].r;
- else
- return {-1, oldMMRtnVal, oldMMRtnVal, "memoryCP_setModMemMgr: bad command: '{newMM}'."};
-
- if not mmList[2]
- return {-1,oldMMRtnVal, oldMMRtnVal,
- "Modern Memory Manager section is not visible; can not set it to {newMM}{symbolicValue}."};
- end;
- else
- return {0, oldMMRtnVal, "{newMM}", "Modern Memory Manager is already {newMM}."};
-
- if clickRect
- begin
- _Move('a', centerOf(clickRect)); # reach out and touch someone
- _Click();
- if newMM = 'On' and not _Match(mmList[3]).s[1] or
- newMM = 'Off' and not _Match(mmList[2]).s[1]
- return {-1, oldMMRtnVal, oldMMRtnVal, "Attempt to set Modern Memory Manager to {newMM} failed."};
- end;
-
- return {0, oldMMRtnVal, "{newMM}", "Set Modern Memory Manager to {newMM}{symbolicValue}."};
- end;
-
-
- #########################################################################
- # Task memoryCP_setVM( vmParams, (*previousVM,*) v_level )
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Sets the Virtual Memory section of the Memory CP.
- # Parameters: vmParams: see MemoryCP()
- # previousVM: when changing from 32-Bit mode to 24-Bit mode, the VM value
- # is truncated at around 13MB if it is higher than the maximum
- # allowable value in 24-bit mode on that machine (including
- # NuBus cards). Obviously, this is not the "real" previous
- # value. To make sure we can return the real one, the main
- # task, MemoryCP, reads the VM value, sets the 32-Bit section,
- # then sets the VM section, feeding the previous VM value in
- # through previousVM. It's gross but it should work reliably.
- # (removed previous VM, see below).
- # v_level: verbosity level
- # Returns: vmParams contains a false value: { 0,'','','' }
- # no section of this type: false
- # bad command: { -1,"{currentVM}","{currentVM}",string }
- # set failed: { -1,"{previousVM}","{newVM}",string }
- # read: { 0,"{currentVM}","{currentVM}",string }
- # set: { 0,"{previousVM}","{newVM}",string }
- # Off: { 0,"{previousVM}","Off",string }
- # Too much RAM in 24-Bit: {0, oldVMRtnVal, oldVMRtnVal, string};
- # Examples: memoryCP_setVM( { '75%' },2 ); (set to 75% of maximum, verbosity 2)
- # memoryCP_setVM( '23M' ); (set to 23M)
- # memoryCP_setVM( '0' ); (turn Off)
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 01/23/93 SBR Created
- # 03/13/93 SBR Removed previousVM because it is too gross. This function
- # should return the same value if called from the main task
- # or called seperately.
- # 09/27/96 BRL/MSO Added SPEC exception handling
- # 03/20/97 SBR Changed v_level to 4.
- # Use previously calculated left-top value.
- # Special-case item locations for 8.0.
- # Use StaticText for vmSizeMax and vmBuiltIn.
- # 02/23/98 SBR Added case 48 for system 8.1.
- # Removed cases for alpha versions of system 8.0.
- # Increased default megsPerSecond to 50 + (megsToGo / 4).
- #########################################################################
- Task memoryCP_setVM( vmParams := 'read', (*previousVM := {},*) v_level := 4 )
- begin
- global gmcp;
- symbolicValue := '';
-
- if not vmParams
- return {0,{},{},''};
- RStatus("memoryCP_setVM with vmParams = {vmParams}",v_level);
-
- memoryCP_getWindowItems();
- vmList := assoc('vm', gmcp);
- b32List := assoc('32', gmcp); # Need 32-bit setting to calculate max VM size
- udList := assoc('ud', gmcp); # need version of mcp to calculate vm offsets
-
- if typeOf(vmParams) = 'list'
- begin
- if typeOf(vmParams[2]) = 'string' begin
- newVM := vmParams[1]; # 2nd item is backing store volume name (unique)
- newVMBSVol := vmParams[2];
- end;
- end;
- else
- newVM := vmParams;
-
- if typeOf(newVM) = 'list'
- begin
- minAutoSize := newVM[1]; # 'auto', but adjust to fit in {low, high} inclusive
- maxAutoSize := newVM[2];
- newVM := 'auto';
- end;
- else begin
- minAutoSize := 0; # 'auto', but adjust to fit in {low, high} inclusive
- maxAutoSize := 0;
- end;
-
- if not vmList
- return RIncomplete("Virtual Memory section is not in this window. Can not set it to '{newVM}'.");
-
- # Do not remove any lines below, even if commented
- vmLT := vmList[1]; # Left Top of VM section in global coordinates
- move_mouse({'absolute',vmLT}); # Indicate current section to human
-
- # switch (udList[2]).o #udOrdinal
- # begin
- # case 48: # System 8.1
- # case 49: # System 8.0
- # case 56: # System 7.6
- # begin
- # # All GM systems thus far have the "correct" VMSizeOffset.
- # vmSizeOffset := { 285,75 };
- # end;
- #
- # default:
- # begin
- # All GM systems thus far have the "correct" VMSizeOffset.
- vmSizeOffset := { 285,75 };
- # end;
- # end;
-
- # vmIconLT := offset_list( vmLT, { 11,33 } ); # VM icon
- vmUp := offset_list( vmLT, { 335,73 } ); # VM set size up arrow
- vmDown := offset_list( vmLT, { 335,83 } ); # VM set size down arrow
- vmHDLT := offset_list( vmLT, { 299,43 } ); # VM available on disk 1st char Left Top
- vmRAMLT := offset_list( vmLT, { 299,56 } ); # VM available built-in memory 1st char Left Top
- vmSizeLT := offset_list( vmLT, vmSizeOffset ); # VM after restart size 1st char Left Top
- # vmMsgLT := offset_list( vmLT, { 171,73 } ); # VM after restart msg 1st char Left Top
- # vmMsgRB := offset_list( vmMsgLT, { 110,12 } ); # VM after restart msg 1st char Right Bottom
- # Do not remove any lines above, even if commented
-
- # if previousVM begin # took out previousVM, but maybe…
- # if typeOf(previousVM) = 'list'
- # oldVMRtnVal := previousVM[1];
- # else oldVMRtnVal := previousVM;
- # end;
- # else
- # begin
-
- oldVM := readGeneva9Number(vmSizeLT);
- if oldVM
- oldVMRtnVal := {"{oldVM}M",''};
- else oldVMRtnVal := {'Off',''};
-
- # end;
-
- #println 'newVM: ',newVM;
- #println 'oldVMRtnVal: ',oldVMRtnVal;
- vmDisabledString := 'Virtual Memory is disabled. There is no size value to measure.';
-
- badCommand := true; # we might not recognize this command
-
- if newVM = 'read'
- return {0, oldVMRtnVal, oldVMRtnVal, "Current VM setting is {oldVMRtnVal}"};
- else if (newVM = 'auto')
- begin
- clickVMOnButton(vmList[3]);
- _Move('a', centerOf(vmList[2].r));
- _Click();
- clickVMOnButton(vmList[3]);
- temp := readGeneva9Number(vmSizeLT);
- if temp
- tempStr := "{temp}M";
- else
- tempStr := '';
- if (not temp) or _Match(vmList[2]).s[1] or (not _Match(vmList[3]).s[1])
- return {-1, oldVMRtnVal, tempStr, 'Attempt to set Virtual Memory automatically failed.'};
- if minAutoSize and (temp < minAutoSize)
- newVM := "{minAutoSize}M";
- else if maxAutoSize and (temp > maxAutoSize)
- newVM := "{maxAutoSize}M";
- else
- return {0, oldVMRtnVal, tempStr, "Automatically set Virtual Memory to {temp}M."};
- end;
-
- else if newVM = 'Off' or newVM = '0M' or newVM = '0%'
- begin
- _Move('a', centerOf(vmList[2].r));
- _Click();
- temp := readGeneva9Number(vmSizeLT);
- if temp
- temp := "{temp}M";
- else
- temp := '';
- if temp or not _Match(vmList[2]).s[1] or _Match(vmList[3]).s[1] #something wrong
- return {-1, oldVMRtnVal, temp, 'Attempt to turn Off Virtual Memory failed.'};
- return {0, oldVMRtnVal, 'Off', 'Turned Off Virtual Memory.'};
- end;
-
- else if newVM = 'On'
- begin
- clickVMOnButton(vmList[3]);
- temp := readGeneva9Number(vmSizeLT);
- if temp
- temp := "{temp}M";
- else
- temp := '';
- if not temp or _Match(vmList[2]).s[1] or not _Match(vmList[3]).s[1]
- return {-1, oldVMRtnVal, temp, 'Attempt to turn On Virtual Memory failed.'};
- return {0, oldVMRtnVal, temp, "Turned On Virtual Memory. It was already set to {temp}."};
- end;
-
- if b32List[2] # first check for 32-Bit mode 'On' by the buttons
- cur32 := (_Match(b32List[3])).s[1];
- else
- begin # if no buttons then by Gestalt
- temp := _Gestalt('addr')[2];
- cur32 := temp - (temp / 2) * 2; # if bit 1 set then 32-Bit mode, else 24-Bit mode
- end;
-
- if cur32
- begin
- # max VM = Available on disk, when 32-bit is On
- switch (udList[2]).o #udOrdinal
- begin
- case 48: # System 8.1
- case 49: # System 8.0
- begin
- # A match is faster than reading digits with VUAid, if possible.
- try
- match [staticText o:10 t:?vmSizeMax w:1]!;
- catch theError
- ExceptionDispatcher(theError,,{"match max VM size in memoryCP_setVM", {v_level}});
-
- theNum := '';
- numChars := card vmSizeMax;
- for i := (numChars - 1) to 1 step -1
- begin
- theChar := vmSizeMax[i];
- if (theChar ~= /[0-9]/)
- theNum := theChar + theNum;
- else
- i := 0;
- end;
- vmSizeMax := strToNum(theNum);
- end;
-
- default:
- begin
- vmSizeMax := readGeneva9Number(vmHDLT);
- end;
- end;
-
- end;
- else
- begin
- vmSizeMax := 13; # otherwise max VM = 16M - 1M(ROM) - 1M(IO)
- end;
-
- # vmBuiltIn := readGeneva9Number(vmRAMLT);
- try
- match [staticText o:11 t:?vmBuiltIn w:1]!;
- catch theError
- ExceptionDispatcher(theError,,{"match VM built-in RAM in memoryCP_setVM", {v_level}});
-
- theNum := '';
- numChars := card vmBuiltIn;
- for i := (numChars - 1) to 1 step -1
- begin
- theChar := vmBuiltIn[i];
- if (theChar ~= /[0-9]/)
- theNum := theChar + theNum;
- else
- i := 0;
- end;
- vmBuiltIn := strToNum(theNum);
-
- if vmBuiltIn > 8 and not cur32
- begin
- badVM := "The CPU has {vmBuiltIn}M built in RAM. You can not use VM in 24-bit mode";
- rdList := assoc('rd', gmcp);
- if rdList
- badVMEnd := " unless you make a RAM disk to reduce the built in RAM to below 8.";
- else badVMEnd := ".";
- return {0, oldVMRtnVal, oldVMRtnVal, badVM + badVMEnd};
- end;
-
- #println "vmBuiltIn: {vmBuiltIn}";
- vmSizeMin := 1 + vmBuiltIn;
-
- badCommand := false; # skip the 'xM' parsing without being a bad command
- if newVM = 'random'
- begin
- symbolicValue := " ({newVM})";
- newVM := random(vmSizeMin,vmSizeMax);
- end;
- else if newVM = 'max'
- begin
- symbolicValue := " ({newVM})";
- newVM := vmSizeMax;
- end;
- else if newVM = 'min'
- begin
- symbolicValue := " ({newVM})";
- newVM := vmSizeMin;
- end;
- else begin
- badCommand := true; # still not a good command
- lastCharIndex := card newVM; # at this point we are parsing 'xM' or 'x%'
- lastChar := newVM[lastCharIndex];
- if lastChar = 'M' or lastChar = '%'
- begin
- theNum := '';
- for i := 1 to lastCharIndex - 1
- theNum := theNum + newVM[i];
- theNum := strToNum(theNum);
- if not isUndefined(theNum)
- begin
- if theNum >= 0
- begin
- badCommand := false; # we recognize the command
- newVM := theNum;
- end;
- end;
- end;
- if badCommand
- return {-1, oldVMRtnVal, oldVMRtnVal, "memoryCP_setVM: '{newVM}' is a bad command."};
-
- if newVM = oldVM
- return {0, oldVMRtnVal, oldVMRtnVal, "Virtual Memory was already {newVM}M."};
-
- # newVM should be a positive integer, check for bounds
- if newVM < vmSizeMin
- begin
- vmBadMsg := "{newVM}M is below minimum ({vmSizeMin}M).";
- newVM := vmSizeMin;
- end;
- else if newVM > vmSizeMax
- begin
- if cur32
- begin
- vmBadMsg := "{newVM}M is above Available space on disk ({vmSizeMax}M).";
- newVM := vmSizeMax;
- end;
- else begin
- vmBadMsg :=
- "{newVM}M is above {vmSizeMax}M, the maximum in 24-Bit mode.";
- newVM := vmSizeMax;
- end;
- end;
- end;
-
- clickVMOnButton(vmList[3]);
-
- if oldVM
- curVMSize := oldVM;
- else
- curVMSize := readGeneva9Number(vmSizeLT);
- prevVMSize := 0; # to check if size did not change after clicking
- #println 'newVM: ', newVM;
- #println 'curVMSize: ', curVMSize;
-
- firstTimePress := true;
- while curVMSize <> newVM and curVMSize <> prevVMSize
- begin
- prevVMSize := curVMSize;
- pressTimeActual := 0;
- pressTimeWait := 0;
- megsToGo := newVM - curVMSize;
- if megsToGo > 0
- _Move('a', vmUp);
- else
- begin
- _Move('a', vmDown);
- megsToGo := 0 - megsToGo; # megsToGo must be >= 0
- end;
-
- #Initially, estimate the VM size rate of change; calculate it afterwards.
- if firstTimePress or (megsToGo < megsPerSecond)
- begin
- megsPerSecond := 50 + (megsToGo / 4); # progressive speedup
- firstTimePress := false;
- end;
-
- if (megsToGo < megsPerSecond) or (megsToGo < 10) # click one at a time
- begin
- maxClicks := megsPerSecond / 2;
- for i := 1 to (megsToGo / maxClicks) # click slow so target will not lose events
- begin
- for j := 1 to maxClicks
- _Click();
- wait(1);
- megsToGo := megsToGo - maxClicks;
- end;
- for j := 1 to megsToGo
- _Click();
- end;
- else
- begin # press for variable intervals
- pressTimeEst := megsToGo / megsPerSecond;
- startTime := _Match([time]);
- _PressMouse();
- pressTimeWait := wait(pressTimeEst);
- pressTimeWait := pressTimeWait.s + 60 * pressTimeWait.m;
- _ReleaseMouse();
- pressTimeActual := time_sub(_Match([time]), startTime);
- pressTimeActual := pressTimeActual[1] + 60 * pressTimeActual[2];
- end;
- tempVMSize := readGeneva9Number(vmSizeLT);
- if pressTimeActual
- begin
- megsPerSecond := (tempVMSize - curVMSize)/pressTimeActual;
- if megsPerSecond < 0
- megsPerSecond := 0 - megsPerSecond;
- end;
- curVMSize := tempVMSize;
- end; # curVMSize <> newVM and curVMSize <> prevVMSize
-
- if curVMSize = prevVMSize # we reached an unexpected stopping point, e.g. in 24-bit mode
- vmOKMsg := "Could not reach {newVM}M{symbolicValue}. Stopped at {curVMSize}M.";
- else
- vmOKMsg := "Set VM to {newVM}M{symbolicValue}.";
-
- if vmBadMsg
- return {-1, oldVMRtnVal, "{curVMSize}M", "Set VM to {curVMSize}M{symbolicValue}. {vmBadMsg}"};
- else
- return {0, oldVMRtnVal, "{curVMSize}M", vmOKMsg};
- end;
-
-
- #########################################################################
- # Task memoryCP_set32Bit( new32, v_level )
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Sets the 32-Bit Addressing section of the Memory CP.
- # Parameters: new32: see MemoryCP()
- # v_level: verbosity level
- # Returns: new32 contains a false value: { 0,'','','' }
- # bad command, command failed, or no section of this type:
- # { -1,"{currentOffOn}","{currentOffOn}",string }
- # read: { 0,"{currentOffOn}","{currentOffOn}",string }
- # set: { 0,"{previousOffOn}","{newOffOn}",string }
- # Examples: memoryCP_set32Bit( 'Off' );
- # Assumptions: see MemoryCP()
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 01/23/93 SBR Created
- # 09/27/96 BRL/MSO Added SPEC exception handling
- # 03/20/97 SBR Changed v_level to 4.
- # Use previously calculated left-top value.
- #########################################################################
- Task memoryCP_set32Bit( new32 := 'read', v_level := 4 )
- begin
- global gmcp;
- symbolicValue := '';
-
- if not new32
- return {0,'','',''};
- RStatus("memoryCP_set32Bit with new32 = {new32}",v_level);
-
- memoryCP_getWindowItems();
- b32List := assoc('32', gmcp);
-
- if b32List[2]
- begin
- b32LT := b32List[1]; # Left Top of 32-bit section in global coordinates
- move_mouse({'absolute',b32LT}); # Indicate current section to human
-
- old32 := _Match(b32List[3]).s[1];
- end;
- else
- begin # no 32-Bit section
- temp := _Gestalt('addr')[2];
- old32 := temp - (temp / 2) * 2; # if bit 1 set then 32-Bit mode, else 24-Bit mode
- end;
-
- if old32
- old32RtnVal := 'On';
- else
- old32RtnVal := 'Off';
-
- if new32 = 'read'
- return {0, old32RtnVal, old32RtnVal, "Current 32-Bit setting is {old32RtnVal}"};
- else if new32 = 'random'
- begin
- symbolicValue := " ({new32})";
- new32 := { 'Off','On' }[random(1,2)];
- end;
-
- if new32 <> old32RtnVal
- begin
- if new32 = 'On'
- clickRect := b32List[3].r;
- else if new32 = 'Off'
- clickRect := b32List[2].r;
- else
- return {-1, old32RtnVal, old32RtnVal, "memoryCP_set32Bit: bad command: '{new32}'."};
-
- if not b32List[2]
- return {-1,old32RtnVal, old32RtnVal,
- "32-Bit section was not visible; could not set it to {new32}{symbolicValue}."};
- end;
- else
- return {0, old32RtnVal, "{new32}", "32-Bit was already {new32}{symbolicValue}."};
-
- if clickRect
- begin
- _Move('a', centerOf(clickRect)); # reach out and touch someone
- _Click();
- if new32 = 'On' and not _Match(b32List[3]).s[1] or
- new32 = 'Off' and not _Match(b32List[2]).s[1]
- return {-1, old32RtnVal, old32RtnVal, "Attempt to set 32-Bit to {new32} failed."};
- end;
-
- return {0, old32RtnVal, "{new32}", "Set 32-Bit to {new32}{symbolicValue}."};
- end;
-
-
- #########################################################################
- # Task memoryCP_setRAMDisk( newRD, v_level )
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Sets the RAM Disk section of the Memory CP.
- # Parameters: newRD: see MemoryCP()
- # v_level: verbosity level
- # Returns: newRD contains a false value: { 0,'','','' }
- # no section of this type: false
- # bad command, command failed:
- # { -1,"{currentRamDisk}","{currentRamDisk}",string }
- # set failed: { -1,"{previousRamDisk}","{newRamDisk}",string }
- # read: { 0,"{currentRamDisk}","{currentRamDisk}",string }
- # set: { 0,"{previousRamDisk}","{newRamDisk}",string }
- # Off: { 0,"{previousRamDisk}","Off",string }
- # Examples: memoryCP_setRAMDisk( '33%',2 ); (set to 33% of maximum, verbosity 2)
- # memoryCP_setRAMDisk( '12348K' ); (set to 12348K)
- # memoryCP_setRAMDisk( '0ff' ); (turn Off, do not return previous size)
- # Assumptions: see MemoryCP()
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 01/23/93 SBR Created
- # 06/25/93 SBR Uses returnString = true for ReadGeneva9Numbers()
- # 09/14/94 SBR Switched to VU 2.1 with genuine long integers
- # 09/27/96 BRL/MSO Added SPEC exception handling
- # 03/20/97 SBR Changed v_level to 4.
- # Use previously calculated left-top value.
- # Special-case item locations for 8.0.
- # 02/23/98 SBR Added case 48 for system 8.1.
- # Removed cases for alpha versions of system 8.0.
- #########################################################################
- Task memoryCP_setRAMDisk( newRD := 'read', v_level := 4 )
- begin
- global gmcp, gRDSizeMin, gRDSizeMax;
-
- sliderWait := 200; # milliseconds to wait when sliding
- if not newRD
- return {0,'','',''};
- RStatus("memoryCP_setRAMDisk with newRD = {newRD}", v_level);
-
- memoryCP_getWindowItems();
- rdList := assoc('rd', gmcp);
- udList := assoc('ud', gmcp); # need version of mcp to calculate rd offsets
-
- if not rdList
- return RIncomplete("RAM Disk section is not in this window. Can not set it to '{newRD}'.");
-
- rdLT := rdList[1]; # Left Top of RAM Disk section in global coordinates
- move_mouse({'absolute',rdLT}); # Indicate current section to human
-
- # rdKnobRect := offset_list( rdLT, { 197,61,212,79 } ); # slider knob rectangle, max RAM disk
- # rdKnobRect := offset_list( rdLT, { 165,29,180,46 } ); # slider knob rectangle, min RAM disk
-
- # before comparing. VU 2.1 detects this offset and corrects for it internally.
- #
- switch (udList[2]).o #udOrdinal
- begin
- case 48: # System 8.1
- case 49: # System 8.0
- begin
- # Post 8.0 has the "new correct" dcSizeOffset.
- rdSizeOffset := { 272,66 };
-
- rdSliderMinOffset := { 183,34 };
- rdSliderMaxOffset := { 302,34 };
- end;
-
- case 56: # System 7.6
- begin
- rdSizeOffset := { 271,66 };
- rdSliderMinOffset := { 180,38 };
- rdSliderMaxOffset := { 305,38 };
- end;
-
- default:
- begin
- rdSizeOffset := { 273,66 };
- rdSliderMinOffset := { 172,38 };
- rdSliderMaxOffset := { 297,38 };
- end;
- end;
-
- rdSizeLT := offset_list( rdLT, rdSizeOffset ); # left top of first digit in size box
- rdSliderMin := offset_list( rdLT, rdSliderMinOffset ); # center of slider, min RAM disk
- rdSliderMax := offset_list( rdLT, rdSliderMaxOffset ); # center slider, max RAM disk
- rdPixel := { 0,rdSliderMax[1] - rdSliderMin[1] }; # {pixel position, total possible}
-
- oldRD := readGeneva9Number(rdSizeLT);
- if oldRD
- oldRDRtnVal := "{oldRD}K";
- else
- oldRDRtnVal := 'Off';
-
- rdEnabled := _Match(rdList[4]).e; #check for On button enabled (RAM Disk empty or Off)
- rdDisabledString := "RAM Disk controls are disabled. Current size is {oldRDRtnVal}.";
-
- if isMember(newRD, { 'Off','0K','0%','0%!' })
- begin
- rdValueAfterTurningOff := 0;
- if oldRD = 0
- offMsg := 'RAM Disk was already Off.';
- else
- begin
- if not rdEnabled
- return {-1, oldRDRtnVal, oldRDRtnVal, rdDisabledString};
- _Move('a', centerOf(rdList[3].r));
- _Click(); # click the Off button
- rdValueAfterTurningOff := readGeneva9Number(rdSizeLT);
- offMsg := 'Turned Off RAM Disk.';
- end;
-
- if rdValueAfterTurningOff
- rdValueAfterTurningOff := "{temp}K";
- else
- rdValueAfterTurningOff := '';
-
- if ( rdValueAfterTurningOff or # non-zero value or buttons wrong
- ( not _Match(rdList[3]).s[1]) or _Match(rdList[4]).s[1] )
- return {-1, oldRDRtnVal, temp, 'Attempt to turn Off RAM Disk failed.'};
- return {0, oldRDRtnVal, 'Off', offMsg};
- end;
-
- badCommand := true; # we might not recognize this command
-
- lastChar := newRD[card newRD];
- setByK := lastChar = 'K';
- setByPixPercent := lastChar = '%';
- setByKPercent := newRD[(card newRD) - 1] = '%' and lastChar = '!';
-
- if setByK or setByPixPercent or setByKPercent # normal path to set rd to a value
- begin
- theNum := '';
- if setByKPercent
- tossOut := 2; # remove '%!' at the end
- else
- tossOut := 1; # remove '%' or 'K' at the end
- for i := 1 to (card newRD) - tossOut
- theNum := theNum + newRD[i];
- theNum := strToNum(theNum);
-
- if theNum >= 0
- begin
- if ((setByPixPercent or setByKPercent) and theNum <= 100) or setByK
- begin
- badCommand := false; # we recognize the command
- newRD := theNum;
- if newRD = oldRD
- return {0, oldRDRtnVal, oldRDRtnVal, "RAM Disk is already {newRD}K."};
- end;
- else
- setByPixPercent := false;
- end;
- end;
-
- if newRD = 'read'
- return {0, oldRDRtnVal, oldRDRtnVal, "Current RAM Disk size is {oldRDRtnVal}."};
-
- newRDPixMethod := isMember(newRD, {'random','min','max'});
- if newRDPixMethod or setByPixPercent
- begin
- # We do all of these methods by moving the slider in units of pixels
- # Off has same likelihood as other settings
- switch newRDPixMethod
- begin
- case 0: # setByPixPercent
- thePixel := 1 + (newRD * rdPixel[2]) / 100;
- case 1: # newRD = 'random'
- thePixel := random(0,rdPixel[2] + 1);
- case 2: # newRD = 'max'
- thePixel := rdPixel[2] + 1;
- case 3: # newRD = 'min'
- thePixel := 1;
- end;
-
- if not rdEnabled
- return {-1, oldRDRtnVal, oldRDRtnVal, rdDisabledString};
-
- _Move('a', centerOf(rdList[3].r)); # turn RAM Disk Off first
- _Click();
- if thePixel > 0 # leave it Off if random chooses zero
- begin
- _Move('a', centerOf(rdList[4].r));
- _Click();
- _Move('a', rdSliderMin);
- wait(0,0,0,sliderWait);
- _PressMouse();
- wait(0,0,0,sliderWait);
- _Move('r', { thePixel - 1,0 });
- wait(0,0,0,sliderWait);
- _ReleaseMouse();
- end;
- rdSettingByPixel := readGeneva9Number(rdSizeLT);
- if setByPixPercent
- strEnd := "% by pixel";
- else
- strEnd := '';
- return {0, oldRDRtnVal,
- "{rdSettingByPixel}K", "Set RAM Disk to {rdSettingByPixel}K ({newRD}{strEnd})."};
- end;
-
- if badCommand # if we reached here then newRD is a bad command
- return {-1, oldRDRtnVal, oldRDRtnVal, "memoryCP_setRAMDisk: '{newRD}' is a bad command."};
-
- if not rdEnabled
- return {-1, oldRDRtnVal, oldRDRtnVal, rdDisabledString};
-
- clickAt := {rdList[3].r, rdList[4].r}; # turn Off then On, now it's at minimum
- for each at in clickAt
- begin
- _Move('a', centerOf(at));
- _Click();
- end;
-
- if isUndefined(gRDSizeMin)
- gRDSizeMin := readGeneva9Number(rdSizeLT); # read minimum RAM disk size
-
- if (newRD < gRDSizeMin) and setByK
- return {-1, oldRDRtnVal, "{gRDSizeMin}K",
- "New size ({newRD}K) was below minimum ({gRDSizeMin}K). Used minimum size."};
-
- _Move('a', rdSliderMin);
- wait(0,0,0,sliderWait);
- _PressMouse();
- wait(0,0,0,sliderWait);
- _Move('a', rdSliderMax);
- wait(0,0,0,sliderWait);
- _ReleaseMouse();
-
- if isUndefined(gRDSizeMax)
- gRDSizeMax := readGeneva9Number(rdSizeLT); # read maximum RAM disk size
-
- if newRD > gRDSizeMax
- return {-1, oldRDRtnVal, "{gRDSizeMax}K",
- "New size ({newRD}) was above maximum ({gRDSizeMax}). Used maximum size."};
-
- rdSizeAttempt := newRD; # If we get here we are going to set RD to a specific value
-
- spread := gRDSizeMax - gRDSizeMin;
- if setByKPercent
- begin
- rdSizeAttempt := newRD * spread;
- rdSizeAttempt := rdSizeAttempt / 100;
- rdSizeAttempt := rdSizeAttempt + gRDSizeMin;
- end;
-
- # Several println's are conditionally executed; more efficient to skip if not executed
- printIt := R_BeVerbose(4);
- if printIt
- println "rdSizeAttempt: {rdSizeAttempt}K";
-
- rdControl := _Match(rdList[2]).s;
-
- if printIt
- println "rdControl: {rdControl}";
-
- if rdControl[1] < rdControl[2] # adjust control max to physically possible max
- rdControlMax := rdControl[1]; # for smooth calculating later
- else
- rdControlMax := rdControl[2];
-
- if printIt
- println "rdControlMax: {rdControlMax}";
-
- # set to closest value <= requested size
- if printIt
- println "spread (max - min): {spread}K";
- sizeStep := spread / rdControlMax;
- if printIt
- println "sizeStep: {sizeStep}";
- wantMin := rdSizeAttempt - gRDSizeMin;
- if printIt
- println "wantMin: {wantMin}";
- pixelValue := wantMin / sizeStep;
- if printIt
- println "pixelValue: {pixelValue}";
- pixelValue := pixelValue * 10 + 9; # insert fudge factor
- if printIt
- println "pixelValue: {pixelValue}";
- pixelValue := pixelValue * rdPixel[2];
- if printIt
- println "pixelValue: {pixelValue}";
- pixelValue := pixelValue / rdControlMax;
- if printIt
- println "pixelValue: {pixelValue}";
- pixelValue := pixelValue / 10; # remove fudge factor
- if printIt
- println "pixelValue: {pixelValue}";
-
- nextHigher := (pixelValue + 1) * rdControlMax;
- if printIt
- println "nextHigher: {nextHigher}";
- nextHigher := nextHigher / rdPixel[2];
- if printIt
- println "nextHigher: {nextHigher}";
- nextHigher := nextHigher * sizeStep;
- if printIt
- println "nextHigher: {nextHigher}";
- nextHigher := gRDSizeMin + nextHigher;
- if printIt
- println "nextHigher: {nextHigher}";
-
- _PressMouse();
- wait(0,0,0,sliderWait);
- _Move('r', { pixelValue - rdPixel[2],0 });
- wait(0,0,0,sliderWait);
- _ReleaseMouse();
- curRDSize := readGeneva9Number(rdSizeLT);
- if nextHigher = curRDSize
- begin
- RStatus('RAM Disk pixel value could have been larger!?',4);
- RStatus("RAM Disk ended up at {curRDSize}K, but script was aiming at {rdSizeAttempt}K",1);
- end;
-
- if nextHigher < curRDSize
- begin
- RStatus('RAM Disk value was set to large!? ',1);
- RStatus("RAM Disk ended up at {curRDSize}K, but script was aiming at {rdSizeAttempt}K",1);
- end;
- else if setByK and (curRDSize <> rdSizeAttempt)
- returnMsgEnd := " instead of {rdSizeAttempt}K";
- else
- returnMsgEnd := '';
-
- if setByKPercent
- returnMsgEnd := " ({newRD}% by value; {newRD}% of {gRDSizeMin}-{gRDSizeMax} is {rdSizeAttempt}K)";
- return {0, oldRDRtnVal, "{curRDSize}K", "Set RAM Disk to {curRDSize}K{returnMsgEnd}."};
- end; #memoryCP_setRAMDisk()
-
-
- #########################################################################
- # Task memoryCP_setUseDefaults( newUD, v_level )
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Clicks Use Defaults button in the Memory CP.
- # Parameters: newUD: see MemoryCP()
- # v_level: verbosity level
- # Returns: newUD contains a false value: { 0,'','','' }
- # Use Defaults button is absent or disabled:
- # { -1, {}, {}, string }
- # click: { 0, 'click', 'click', string }
- # Examples: memoryCP_setUseDefaults( 'click' );
- # Assumptions: see MemoryCP()
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 02/11/93 SBR Created
- # 03/20/97 SBR Changed v_level to 4.
- # Use previously calculated left-top value.
- #########################################################################
- Task memoryCP_setUseDefaults( newUD := 'click', v_level := 4 )
- begin
- global gmcp;
- symbolicValue := '';
-
- if not newUD
- return {0,'','',''};
- RStatus("memoryCP_setUseDefaults with newUD = {newUD}",v_level);
-
- memoryCP_getWindowItems();
- udList := assoc('ud', gmcp);
-
- udLT := udList[1]; # Left Top of Use Defaults section in global coordinates
- move_mouse({'absolute',udLT}); # Indicate current section to human
-
- if newUD = 'click'
- begin
- if _MatchBoolean([button t:'Use Defaults'])
- begin
- _Move('a', centerOf(udList[2].r) );
- _Click();
- return {0, 'click', 'click', 'Clicked Use Defaults button.'};
- end;
- else
- return {-1, {}, {}, 'The Use Defaults button was absent or disabled.'};
- end;
- end;
-
-
- #########################################################################
- # Task clickVMOnButton( vmOnButton, v_level )
- # Description: Clicks the On button in the Virtual Memory section of
- # the Memory CP. Handles PowerBook battery message. The
- # descriptor is used because the buttons are offset -89.
- # It is a constructed descriptor, not from a match.
- # Parameters: vmOnButton: the descriptor for the VM On button
- # v_level: verbosity level
- # Returns: nothing
- # History:
- # 01/23/93 SBR Created for use with memoryCP_setVM
- # 09/27/96 BRL/MSO Added SPEC exception handling
- #########################################################################
- Task clickVMOnButton( vmOnButton, v_level := 5 )
- begin
- RStatus("clickVMOnButton with vmOnButton = {vmOnButton}",v_level);
- _Move('a', centerOf(vmOnButton.r) );
- _Click();
- wait(1);
- if _MatchBoolean([staticText t:/Using V≈M≈will reduce your battery life./ w:1], false)
- begin
- _Select([button]);
- while not _MatchBoolean( [window t:'Memory' o:1], true)
- wait(1);
- end;
- end;
-
-
- #########################################################################
- # Task centerOf( r, v_level )
- # Description: Returns the point in the center of rectangle r.
- # Parameters: r: { Left,Top,Bottom,Right }
- # v_level: verbosity level
- # Returns: nothing
- # History:
- # 01/23/93 SBR Created for use with memoryCP_setVM
- #########################################################################
- task centerOf( r := {0,0,0,0}, v_level := 5 )
- begin
- RStatus("centerOf with r = {r}",v_level);
- return { (r[1] + r[3]) / 2 , (r[2] + r[4]) / 2 };
- end;
-